/**
 * @class   wosh::gui::FormConsole
 * @brief   
 *          
 *          
 *
 ****************************************************************************
 * @version $Id: FormConsole.h 2879 2010-08-09 02:41:13Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/
 
#ifndef __WOSH_Gui_FormConsole_H__
 #define __WOSH_Gui_FormConsole_H__

 #include <framework/gui/IWidget.h>
 #include <framework/communication/SessionProxy.h>


namespace Ui {
    class FormConsole;
}
using namespace wosh::communication;
namespace wosh {
 namespace gui {

class FormConsole :	public IWidgetGeneric,
					public virtual ISessionProxyListener
  {
	Q_OBJECT

	WOSH_CLASSNAME(wosh::gui::FormConsole)
	WOSH_CLASS_ABSTRACT(false)


	public:
		FormConsole(QWidget *parent = 0);
		virtual ~FormConsole();


	public slots:
		virtual void refreshAll() { }


	protected:
		WRESULT notify( const Notification* notification );

/** @name ISessionProxyListener Events
 * @{
 ******************************************************************************/
	public:
		void session_registration( short reg_unreg, wosh::communication::SessionProxy* session );
		void session_state_changed( Session::SESSION_STATE new_state, Session::SESSION_STATE old_state, wosh::communication::SessionProxy* session );
		void session_bus_changed( const std::string& , wosh::communication::SessionProxy* );
		void session_location_changed( const URI& , wosh::communication::SessionProxy* );
		WRESULT session_print_message( const std::string& message, wosh::communication::SessionProxy* session );
//@}
	public:

//		virtual void session_StateChanged( wosh::communication::Session::STATE state, SessionAsynch* source );
//		virtual void session_UriChanged( const URI& location, SessionAsynch* source );
//		virtual void session_UsernameChanged( const std::string& username, SessionAsynch* source );

//		virtual void session_PostWelcome( const std::string& message, SessionAsynch* source );
//		virtual void session_PrintMessage( const std::string& message, SessionAsynch* );

//		virtual void session_MessageQueued( Message* message, SessionAsynch* source );
//		virtual void session_MessageParsing( Message* message, SessionAsynch* source );


	protected slots:
		void shellSend();
		void e_onPrintMessage( const QString& message );
		void e_onBusChanged();
		void e_onLocationChanged();

		void txtCurrentBus_editingFinished();
		void txtCurrentKernel_editingFinished();
		void chkScrollAuto_clicked();
		void cmbSessionDebug_activated(int index);
		void cmbWordWrap_activated(int index);
		void btnFontChange_clicked();
		void btnFontColorChange_clicked();
		void btnBackgroundChange_clicked();

	signals:
		void onPrintMessage( const QString& message );
		void onBusChanged();
		void onLocationChanged();

	protected:
		void changeEvent(QEvent *e);
		void closeEvent(QCloseEvent* e);

	protected:
		void busMessage( const Message&, const Bus* ) { }

//		void s_sentMessage( QString message );
//		void s_sessionInfoChanged();

	protected:
		SessionProxy* session;
		bool sessionDebug;
		bool scrollAuto;

	private:
		Ui::FormConsole *m_ui;

}; // class def

 }; // namespace gui
}; // namespace wosh


#endif //__WOSH_Gui_FormConsole_H__
